package com.orhon.smartcampus.modules.base;

import static com.orhon.smartcampus.basicComponents.service.GQLUtil.Lang;

import java.util.HashMap;

import com.orhon.smartcampus.basicComponents.service.DateService;
import com.orhon.smartcampus.modules.base.gqlModel.GQLGrades;
import com.orhon.smartcampus.modules.base.gqlModel.GQLPeriod;
import com.orhon.smartcampus.modules.base.gqlModel.GQLRegion;

public class BaseGQLUtil {

    /**
     * 年级管理
     * @param item
     * @return
     */
    public static GQLGrades grades (HashMap<String, Object> item) {

        GQLGrades gqlGrades = new GQLGrades();
        if(item!=null&&item.size()>0) {
            gqlGrades.setId(Long.valueOf(item.get("id").toString()));
            gqlGrades.setSlug((String)item.get("grade_slug"));
            gqlGrades.setMark((String)item.get("mark"));
            gqlGrades.setNumber((String)item.get("grade_number"));
            gqlGrades.setOrder((Integer) item.get("grade_order"));
            gqlGrades.setPeriods((GQLPeriod)item.get("period_id"));
            gqlGrades.setName(Lang(item.get("grade_name").toString()));
        }
        return gqlGrades;
    }


    /**
     * 学段管理
     * @param item
     * @return
     */
    public static GQLPeriod period (HashMap<String, Object> item) {

        GQLPeriod gqlPeriod = new GQLPeriod();
        if(item!=null&&item.size()>0) {
            gqlPeriod.setId(Long.valueOf(item.get("id").toString()));
            gqlPeriod.setSlug((String)item.get("period_slug"));
            gqlPeriod.setNumber((String)item.get("period_number"));
            gqlPeriod.setOrder((Integer) item.get("period_order"));
            gqlPeriod.setMark((String)item.get("mark"));
            gqlPeriod.setName(Lang(item.get("period_name").toString()));
        }
        return gqlPeriod;
    }

    public static GQLRegion Region (HashMap<String,Object> item) {
        GQLRegion gqlregion = new GQLRegion();
        if(item!=null&&item.size()>0) {
            gqlregion.setId(Long.valueOf(item.get("id").toString()));
            gqlregion.setSlug((String)item.get("region_slug"));
            gqlregion.setLevel((Integer)item.get("level"));
            gqlregion.setOrder((Integer)item.get("region_order"));
            gqlregion.setCreated_at(DateService.convertDbDate(item.get("created_at")));
            gqlregion.setUpdated_at(DateService.convertDbDate(item.get("created_at")));
            gqlregion.setDeleted_at(DateService.convertDbDate(item.get("created_at")));
            gqlregion.setName(Lang(item.get("region_name").toString()));
        }
        return gqlregion;
    }

}
